const express = require("express");
const router = express.Router();
const { success, failure, NotFoundError } = require("../utils/response");
const { Course,Category, User } = require("../models");
/**
 * 查询课程列表
 * GET/
 */
router.get("/", async function (req, res, next) {
  try {
    const categories = await Category.findAll({
      order: [
        ["rank", "DESC"],
        ["id", "DESC"],
      ],
    });

    success(res, "获取首页查询成功", {categories});
  } catch (error) {
    // 如果发生错误，返回错误信息
    failure(res, error);
  }
});

module.exports = router;
